package com.cl.jvppeteerdemo;

import com.cl.jvppeteerdemo.util.PlaywrightUtil;
import com.cl.jvppeteerdemo.util.PuppeteerUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class JvppeteerDemoApplication {

    public static void main(String[] args) throws InterruptedException {
        ConfigurableApplicationContext context = SpringApplication.run(JvppeteerDemoApplication.class, args);
        //url body > div.body_content_wrapper.pb-2.mt-0 > div > section > div > div.col-4 > div.text_list_box.weekly_list.mb-4
//        Page page = PuppeteerUtil.getNewPage("https://escapefromtarkov.fandom.com/wiki/Ballistics", "domcontentloaded", 120000, 1650, 12000);
//
//        ElementHandle b = page.$("div._2O--J403t2VqCuF8XJAZLK");
//        if (b != null) {
//            try {
//                b.click();
//            } catch (InterruptedException | ExecutionException e) {
//                throw new RuntimeException(e);
//            }
//        }

//        ElementHandle elementHandle1 = page.$("table.wikitable.sortable.stickyheader");
//        new Thread(() -> PlaywrightUtil.getBrowserContext()).start();
//      Thread.sleep(5000);
        new Thread(() -> PuppeteerUtil.screenshot("https://www.bilibili.com/opus/840367397241094211", "/o/bl1.png", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
        new Thread(() -> PuppeteerUtil.screenshot("https://www.bilibili.com/opus/840367397241094211", "/o/bl2.png", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
//        new Thread(() -> PuppeteerUtil.screenshot("https://www.bilibili.com/opus/840367397241094211", "bl3.png", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
//        new Thread(() -> PuppeteerUtil.screenshot("https://www.bilibili.com/opus/840367397241094211", "bl4.png", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
//        Thread.sleep(100);
//        new Thread(() -> PuppeteerUtil.screenshot("https://www.bilibili.com/opus/840367397241094211", "bl5.png", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();


//        new Thread(() -> PlaywrightUtil.screenshot("bl2.png", "https://www.bilibili.com/opus/840367397241094211", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
//        Thread.sleep(300);
//        new Thread(() -> PlaywrightUtil.screenshot("bl3.png", "https://www.bilibili.com/opus/840367397241094211", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
//        Thread.sleep(300);
//        new Thread(() -> PlaywrightUtil.screenshot("bl4.png", "https://www.bilibili.com/opus/840367397241094211", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
//        Thread.sleep(300);
//        new Thread(() -> PlaywrightUtil.screenshot("bl5.png", "https://www.bilibili.com/opus/840367397241094211", "#app > div.opus-detail > div.bili-opus-view", ".z-top-container { display: none }")).start();
        Thread.sleep(5000);
        PuppeteerUtil.close();
//        PlaywrightUtil.close();
    }

}
